package com.cloud.basic.feign.weather.demo;

import com.cloud.basic.feign.weather.ArrayOfString;
import com.cloud.basic.feign.weather.WeatherWebService;
import com.cloud.basic.feign.weather.WeatherWebServiceSoap;
import lombok.extern.slf4j.Slf4j;

import javax.xml.ws.Endpoint;
import java.util.List;

/**
 * @program: basic
 * @description:
 * @author: Cloud
 * @create: 2021/10/18 11:29:35
 */
@Slf4j
public class WeatherServer {

    public static void main(String[] args) {
        Endpoint.publish("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl", new WeatherImp());

        // 创建一个WeatherWS工厂
        WeatherWebService factory = new WeatherWebService();
        // 根据工厂创建一个WeatherWSSoap对象
        WeatherWebServiceSoap weatherWSSoap = factory
                .getWeatherWebServiceSoap();
        // 调用WebService提供的getWeather方法获取南宁市的天气预报情况
        ArrayOfString weatherInfo = weatherWSSoap.getWeatherbyCityName("南宁");
        ArrayOfString province = weatherWSSoap.getSupportCity("黑龙江");
        List<String> provinceList = province.getString();
        for (String pro : provinceList) {
            System.out.println(pro);
        }
        List<String> lstWeatherInfo = weatherInfo.getString();
        // 遍历天气预报信息
        for (String string : lstWeatherInfo) {
            System.out.println(string);
            System.out.println("------------------------");
        }
    }
}
